//
//  MapViewWithGrid.h
//  iD20
//
//  Created by Andrew Spina on 5/18/10.
//  Copyright 2010 STScI. All rights reserved.
//

#import <UIKit/UIKit.h>
@protocol MapViewWithGridDelegate;
#import "Point2d.h";

typedef enum {
	DragModeNone, DragModePointOne, DragModePointTwo
} DragMode;

@interface MapGridView : UIView {
	id delegate;
	double gridSize;
	Point2d *firstReferencePoint; // The grid intersection closest to where the user started their first tap.
	Point2d *secondTouchPoint; // The grid intersection closest to where the user started their second tap.
	CGPoint firstTapLocation;
	CGPoint offset; // An offset of (30, 30) means the user has dragged down and to the right.
	DragMode mode;
}

@property (nonatomic, retain) IBOutlet id<MapViewWithGridDelegate> delegate;
@property (nonatomic, assign) double gridSize;
@property (nonatomic, retain) Point2d *firstReferencePoint;
@property (nonatomic, retain) Point2d *secondTouchPoint;
@property (nonatomic, assign) CGPoint firstTapLocation;
@property (nonatomic, assign) CGPoint offset;

-(void) firstTouchAtPoint: (CGPoint) point;
-(void) secondTouchAtPoint: (CGPoint) point;
-(void) firstTapDraggedTo: (CGPoint) dragLocation;
-(void) secondTapDraggedTo: (CGPoint) dragPoint;
-(void) minimizeOffset;
- (Point2d *) convertCGPointToIntersectionLocation: (CGPoint) point;
@end

@protocol MapViewWithGridDelegate<NSObject>

@optional

- (void) mapViewTapped: (MapGridView*) map atX: (double) x Y: (double) y;

@end
